#include "SMPPReplaceSM.hpp"

using namespace smpp::pdu;

ReplaceSM::ReplaceSM(const Header &nHeader,
const CoctetString &nMessageId,
const quint8 nSourceAddrTON,
const quint8 nSourceAddrNPI,
const CoctetString &nSourceAddr,
const CoctetString &nScheduleDeliveryTime,
const CoctetString &nValidityPeriod,
const quint8 nRegisteredDelivery,
const quint8 nSMDefaultMsgId,
const quint8 nSMLength,
const octetString &nShortMessage,
const MessageReplacementTLVs &nMessageReplacementTLVs):
Header(nHeader),
_MessageId(nMessageId),
_SourceAddrTON(nSourceAddrTON),
_SourceAddrNPI(nSourceAddrNPI),
_SourceAddr(nSourceAddr),
_ScheduleDeliveryTime(nScheduleDeliveryTime),
_ValidityPeriod(nValidityPeriod),
_RegisteredDelivery(nRegisteredDelivery),
_SMDefaultMsgId(nSMDefaultMsgId),
_SMLength(nSMLength),
_ShortMessage(nShortMessage),
MessageReplacementTLVs(nMessageReplacementTLVs){}
	
ReplaceSM::ReplaceSM(const ReplaceSM &nReplaceSM):
Header(nReplaceSM),
_MessageId(nReplaceSM.getMessageId()),
_SourceAddrTON(nReplaceSM.getSourceAddrTON()),
_SourceAddrNPI(nReplaceSM.getSourceAddrNPI()),
_SourceAddr(nReplaceSM.getSourceAddr()),
_ScheduleDeliveryTime(nReplaceSM.getScheduleDeliveryTime()),
_ValidityPeriod(nReplaceSM.getValidityPeriod()),
_RegisteredDelivery(nReplaceSM.getRegisteredDelivery()),
_SMDefaultMsgId(nReplaceSM.getSMDefaultMsgId()),
_SMLength(nReplaceSM.getSMLength()),
_ShortMessage(nReplaceSM.getShortMessage()),
MessageReplacementTLVs(nReplaceSM){}

void ReplaceSM::setMessageId(const CoctetString& sMessageId){
	_MessageId = sMessageId;
}

const CoctetString &ReplaceSM::getMessageId() const{
	return _MessageId;
}

void ReplaceSM::setSourceAddrTON(const quint8 nSourceAddrTON){
	_SourceAddrTON = nSourceAddrTON;
}

const quint8 ReplaceSM::getSourceAddrTON() const{
	return _SourceAddrTON;
}

void ReplaceSM::setSourceAddrNPI(const quint8 nSourceAddrNPI){
	_SourceAddrNPI = nSourceAddrNPI;
}

const quint8 ReplaceSM::getSourceAddrNPI() const{
	return _SourceAddrNPI;
}

void ReplaceSM::setSourceAddr(const CoctetString &sSourceAddr){
	_SourceAddr = sSourceAddr;
}

const CoctetString &ReplaceSM::getSourceAddr() const{
	return _SourceAddr;
}

void ReplaceSM::setScheduleDeliveryTime(
	const CoctetString &sScheduleDeliveryTime){
	_ScheduleDeliveryTime = sScheduleDeliveryTime;
}

const CoctetString &ReplaceSM::getScheduleDeliveryTime() const{
	return _ScheduleDeliveryTime;
}

void ReplaceSM::setValidityPeriod(
	const CoctetString &sValidityPeriod){
	_ValidityPeriod = sValidityPeriod;
}

const CoctetString &ReplaceSM::getValidityPeriod() const{
	return _ValidityPeriod;
}

void ReplaceSM::setRegisteredDelivery(const quint8 nRegisteredDelivery){
	_RegisteredDelivery = nRegisteredDelivery;
}

const quint8 ReplaceSM::getRegisteredDelivery() const{
	return _RegisteredDelivery;
}

void ReplaceSM::setSMDefaultMsgId(const quint8 nSMDefaultMsgId){
	_SMDefaultMsgId = nSMDefaultMsgId;
}

const quint8 ReplaceSM::getSMDefaultMsgId() const{
	return _SMDefaultMsgId;
}

void ReplaceSM::setSMLength(const quint8 nSMLength){
	_SMLength = nSMLength;
}

const quint8 ReplaceSM::getSMLength() const{
	return _SMLength;
}

void ReplaceSM::setShortMessage(const octetString &aShortMessage){
	_ShortMessage = aShortMessage;
}

const octetString &ReplaceSM::getShortMessage() const{
	return _ShortMessage;
}

void ReplaceSM::calcCommandLength(){
	_SequenceNumber = 21 + 
		_MessageId.size() + _SourceAddr.size() + 
		_ScheduleDeliveryTime.size() + _ValidityPeriod.size() + 
		_ShortMessage.size() + MessageReplacementTLVs::getLength();
}
